{-# LANGUAGE TypeFamilies #-}
module Weights
    ( w0
    , w0'
    , w1
    , im
    ) where

import           Data.Massiv.Array hiding ( map, zip, unzip )
import qualified Data.Massiv.Array as A

-- > extract' (0 :> 0) (Sz (1 :> 1 :> 5 :. 5)) w0
-- Array M Par (Sz (1 :> 1 :> 5 :. 5))
--   [ [ [ [ -5.34187e-2, -0.42678, -0.3788081, -0.1806156, -0.2589863 ]
--       , [ 0.2156626, 2.298e-3, 0.1362538, 9.06657e-2, 8.78454e-2 ]
--       , [ 0.3264671, 0.3181283, 0.3527859, 0.1273208, 0.1496966 ]
--       , [ 0.1065092, 0.226041, 0.1678512, 0.2619891, 0.1658615 ]
--       , [ -0.2026702, -0.3002051, -0.2787303, -0.3063709, -0.1232836 ]
--       ]
--     ]
--   ]
w0 :: Array U Ix4 Float
w0 = A.resize' (Sz (3 :> 1 :> 5 :. 5)) w
  where
    w = A.fromLists' Par _w0 :: Array U Ix3 Float

w1 :: Array U Ix4 Float
w1 = A.fromLists' Par _w1

w0' :: Array U Ix4 Float
w0' = A.fromLists' Par _w
  where
    _w = [[[[ 0.1529,  0.1660, -0.0469,  0.1837, -0.0438],
          [ 0.0404, -0.0974,  0.1175,  0.1763, -0.1467],
          [ 0.1738,  0.0374,  0.1478,  0.0271,  0.0964],
          [-0.0282,  0.1542,  0.0296, -0.0934,  0.0510],
          [-0.0921, -0.0235, -0.0812,  0.1327, -0.1579]]],

        [[[-0.0922, -0.0565, -0.1203,  0.0189, -0.1975],
          [ 0.1806, -0.1699,  0.1544,  0.0333, -0.0649],
          [ 0.1236,  0.0312,  0.1616,  0.0219, -0.0631],
          [ 0.0537, -0.0542,  0.0842,  0.1786,  0.1156],
          [-0.0874,  0.1155,  0.0358,  0.1016, -0.1219]]],

        [[[-0.1980, -0.0773, -0.1534,  0.1641,  0.0576],
          [ 0.0828,  0.0633, -0.0035,  0.1565, -0.1421],
          [ 0.0126, -0.1365,  0.0617, -0.0689,  0.0613],
          [-0.0417,  0.1659, -0.1185, -0.1193, -0.1193],
          [ 0.1799,  0.0667,  0.1925, -0.1651, -0.1984]]]]

_w0 :: [[[Float]]]
_w0 = [
      [
        [-0.0534187, -0.4267800, -0.3788081, -0.1806156, -0.2589863],
        [0.2156626, 0.0022980, 0.1362538, 0.0906657, 0.0878454],
        [0.3264671, 0.3181283, 0.3527859, 0.1273208, 0.1496966],
        [0.1065092, 0.2260410, 0.1678512, 0.2619891, 0.1658615],
        [-0.2026702, -0.3002051, -0.2787303, -0.3063709, -0.1232836]
      ],
      [
        [0.0551993, 0.1045230, -0.0366117, -0.5920511, -0.0917701],
        [0.1919561, 0.5827265, 0.3099443, -0.4107210, -0.3781265],
        [0.1501214, 0.5768867, 0.2122501, 0.0657311, -0.1822006],
        [0.2167903, 0.0878547, 0.3063964, 0.1100133, -0.0949315],
        [-0.2078952, -0.2011820, 0.0787179, 0.0633503, 0.0581303]
      ],
      [
        [-0.2794258, -0.1741319, -0.0240761, -0.1554422, 0.1576027],
        [0.0955043, 0.0858102, 0.0245369, 0.3348939, 0.1353997],
        [-0.0521553, 0.4255765, 0.4414395, 0.4071167, -0.2855816],
        [-0.0264099, 0.1608194, 0.2087562, -0.2096319, -0.4580663],
        [-0.0295109, -0.0170219, 0.1330078, -0.0520784, 0.0100198]
      ]
      ]

_w1 :: [[[[Float]]]]
_w1 = [
         [
            [
                [-0.0163608, 0.0002715, 0.0074515, -0.1819683, -0.0413035],
                [-0.1975431, -0.1366899, 0.0230231, -0.0019693, 0.0617053],
                [-0.2620012, -0.2170821, 0.0541632, 0.0058990, 0.1601330],
                [-0.2193660, -0.2514228, -0.0132322, 0.0749228, 0.0490924],
                [-0.2299628, -0.0798626, -0.0141146, -0.0257903, 0.0088129]
            ],
            [
                [0.1029933, -0.0063213, 0.0138863, -0.0551134, -0.2057581],
                [-0.0639190, 0.2389061, 0.1199245, 0.1530572, -0.0121181],
                [0.0303116, 0.2447439, 0.3182551, 0.1036975, 0.0604892],
                [0.0265751, 0.2106621, 0.2822360, 0.0341720, -0.0716639],
                [-0.1438569, 0.0491220, 0.1908389, -0.1072943, -0.0623054]
            ],
            [
                [-0.2145886, -0.1210147, 0.0689316, 0.0882591, 0.0193445],
                [-0.1629163, 0.0607957, 0.1507723, 0.0480526, 0.0226661],
                [0.0822811, 0.1029156, 0.0219653, -0.1323442, -0.1255060],
                [-0.0764415, -0.0130525, -0.0806570, 0.0108179, -0.0246550],
                [-0.0454455, 0.0632577, 0.0476086, -0.0164182, -0.1011168]
            ]
        ],
        [
            [
                [0.1160349, 0.1678747, -0.0675207, -0.1474030, -0.2996965],
                [0.0340398, -0.0665236, -0.1371030, -0.0054331, -0.1125873],
                [0.0261097, 0.0763286, 0.0463775, 0.1136572, 0.0215450],
                [0.0539965, -0.0846731, -0.0942227, -0.1680770, -0.0872455],
                [-0.1515556, -0.1222363, -0.1608406, -0.1318540, 0.0632183]
            ],
            [
                [0.5258334, 0.0642202, -0.2208425, -0.2748874, -0.0581117],
                [0.1950866, -0.1999780, -0.3845304, -0.2126902, -0.1749956],
                [0.1549081, -0.3180801, -0.3452494, -0.1036503, -0.0730425],
                [-0.0348187, -0.2150077, -0.2176047, 0.0055309, 0.1039149],
                [-0.1712706, -0.0584516, 0.0332528, 0.1996990, 0.0190856]
            ],
            [
                [-0.0644794, -0.1835168, 0.1137649, 0.0365547, 0.0530593],
                [-0.0619063, -0.0703480, 0.0702534, 0.2002776, 0.2039676],
                [0.0091446, 0.0862363, 0.1379312, 0.3878273, 0.3952508],
                [0.1170122, 0.2015860, 0.1331147, 0.1963690, 0.4071371],
                [-0.1504756, 0.0365199, -0.1046191, 0.0032605, 0.3179584]
            ]
        ],
        [
            [
                [0.0209599, 0.1079975, 0.2399355, 0.2251497, 0.1919641],
                [0.0837070, 0.0662162, 0.2751379, 0.0841925, -0.0093339],
                [0.0949002, 0.0574616, 0.2350854, 0.2016568, -0.0366845],
                [-0.1449816, -0.0007661, 0.0680536, 0.0064419, -0.1097422],
                [-0.1119747, -0.2011822, -0.1744925, -0.1747541, -0.0196573]
            ],
            [
                [0.1271286, -0.0006491, 0.0043801, 0.0024970, -0.1214313],
                [-0.0609811, 0.1307091, 0.1581844, 0.0323703, -0.0759600],
                [0.0492914, 0.1487607, 0.0294329, 0.1590851, -0.0063198],
                [-0.1935208, 0.0075470, -0.1702182, -0.0240462, -0.1674199],
                [-0.1610030, -0.2307567, -0.3194915, -0.2580668, -0.2379227]
            ],
            [
                [-0.1615753, -0.0860038, 0.1310071, 0.1813526, 0.1875222],
                [-0.0571556, 0.0871965, 0.1713926, 0.1218254, -0.0222433],
                [-0.0153635, -0.0720964, 0.0856214, 0.0199662, 0.0315881],
                [-0.0023934, -0.1461371, 0.0019997, 0.1057544, 0.0232654],
                [-0.1568521, -0.1860574, -0.0736405, -0.0441019, -0.0728004]
            ]
        ]
    ]

-- TODO: do not forget image normalization with ((0.1307,), (0.3081,))
-- The first image in MNIST
im :: Array U Ix2 Float
im = A.fromLists' Par _im
  where
    _im = [
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0.0117647,0.0705882,0.0705882,0.0705882,0.494118,0.533333,0.686275,0.101961,0.65098,1,0.968627,0.498039,0,0,0,0],
        [0,0,0,0,0,0,0,0,0.117647,0.141176,0.368627,0.603922,0.666667,0.992157,0.992157,0.992157,0.992157,0.992157,0.882353,0.67451,0.992157,0.94902,0.764706,0.25098,0,0,0,0],
        [0,0,0,0,0,0,0,0.192157,0.933333,0.992157,0.992157,0.992157,0.992157,0.992157,0.992157,0.992157,0.992157,0.984314,0.364706,0.321569,0.321569,0.219608,0.152941,0,0,0,0,0],
        [0,0,0,0,0,0,0,0.0705882,0.858824,0.992157,0.992157,0.992157,0.992157,0.992157,0.776471,0.713725,0.968627,0.945098,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0.313725,0.611765,0.419608,0.992157,0.992157,0.803922,0.0431373,0,0.168627,0.603922,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0.054902,0.00392157,0.603922,0.992157,0.352941,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0.545098,0.992157,0.745098,0.00784314,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0.0431373,0.745098,0.992157,0.27451,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0.137255,0.945098,0.882353,0.627451,0.423529,0.00392157,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0.317647,0.941176,0.992157,0.992157,0.466667,0.0980392,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.176471,0.729412,0.992157,0.992157,0.588235,0.105882,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.0627451,0.364706,0.988235,0.992157,0.733333,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.976471,0.992157,0.976471,0.25098,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.180392,0.509804,0.717647,0.992157,0.992157,0.811765,0.00784314,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0.152941,0.580392,0.898039,0.992157,0.992157,0.992157,0.980392,0.713725,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0.0941176,0.447059,0.866667,0.992157,0.992157,0.992157,0.992157,0.788235,0.305882,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0.0901961,0.258824,0.835294,0.992157,0.992157,0.992157,0.992157,0.776471,0.317647,0.00784314,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0.0705882,0.670588,0.858824,0.992157,0.992157,0.992157,0.992157,0.764706,0.313725,0.0352941,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0.215686,0.67451,0.886275,0.992157,0.992157,0.992157,0.992157,0.956863,0.521569,0.0431373,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0.533333,0.992157,0.992157,0.992157,0.831373,0.529412,0.517647,0.0627451,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
      ]
